#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int* shortestToChar(char* s, char c, int* returnSize) {
    int len = strlen(s);
    int* ans = (int*)malloc(sizeof(int) * len);
    *returnSize = len;
    for (int i = 0; i < len; i++)
    {
        int len1 = 10000, len2 = 10000;
        for (int j = i; j < len; j++)
        {
            if (s[j] == c)
            {
                len1 = j;
                break;
            }
        }
        for (int j = i; j >= 0; j--)
        {
            if (s[j] == c)
            {
                len2 = j;
                break;
            }
        }
        ans[i] = abs(i - len1) < abs(i - len2) ? abs(i - len1) : abs(i - len2);
    }
    return ans;
}

int main()
{
    char str[] = { "baaa" };
    int sz = 1;
    char c = 'b';
    shortestToChar(str, c, &sz);
    return 0;
}